<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>喜欢的水果： <label><input type="checkbox" value="苹果" name="check" />苹果</label>
        <label><input type="checkbox" value="西瓜" name="check" />西瓜</label>
        <label><input type="checkbox" value="蜜桃" name="check"/>蜜桃</label>
    </p>
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
    <script>
        var ch = $("input[type='checkbox']")
        var text = "";
        console.log(ch);
    for(var j = 0;j<ch.length;j++){
        ch[j].onchange =()=>{
       for(var i = 0;i<ch.length;i++){
            if(ch[i].checked ){
              text += ch[i].value;

            //   ch[i].checked = false;
            }
       }
    
       alert(text);
       text="";
    }
    }
    // $("input[type =checkbox]").click(function(){
    //     if($("input[name ='check']:checked"))
    // })
    </script>
</body>
</html>